# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=smtp-test
pkgver=6.151f636
pkgrel=2
groups=('blackarch' 'blackarch-scanner')
pkgdesc='Automated testing of SMTP servers for penetration testing.'
arch=('any')
url='https://github.com/isaudits/smtp-test'
license=('custom:unknown')
depends=('python2' 'python2-dnspython' 'python2-configparser' 'cutycapt' 'nmap')
makedepends=('git')
source=("git+https://github.com/isaudits/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"

  mv "$pkgdir/usr/share/$pkgname/config/config.example" \
    "$pkgdir/usr/share/$pkgname/config/default.example"
}

